package com.jiazhong.shixi.book.mapper;

import com.jiazhong.shixi.book.bean.ShoppingCart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    //
     //查看购物车
    @Select("select * from shopping_cart where user_id=#{user_id} and is_deleted=0")
    List<ShoppingCart> shopping_look(String user_id);
    //添加购物车
    @Insert("   insert into shopping_cart values(null,#{user_id},1,#{book_id}),0")
    void add(ShoppingCart sc);
    //更改购物车数量
    @Update("update shopping_cart set number=number+#{number} where user_id=#{user_id} and book_id=#{book_id} and is_deleted=0")
    void update(ShoppingCart sc);
    //逻辑删除
    @Update("update shopping_cart set is_deleted=1 where user_id=#{user_id} and book_id=#{book_id}")
    void shan(ShoppingCart sc);
    //逻辑全删
    @Update("update shopping_cart set is_deleted=1 where user_id=#{user_id}")
    void all(ShoppingCart sc);
}
